package com.xingzhe.pengji.security.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.xingzhe.pengji.security.domain.Authorite;
import com.xingzhe.pengji.security.mapper.provider.AuthoriteSqlProvider;

/**
 * @Title ： 三江学院 毕业设计
 * @Description ：
 * @author ：LuFengLiang
 * @Company: IT行者工作室
 * @Copyright: Copyright (c) 2012-2-24
 * @version ： 1.0
 * @param <T>
 */
public interface AuthoriteMapper<T extends Authorite> extends SqlMapper<T>
{

    final String AUTHORITE_RESULT_MAP = "com.xingzhe.pengji.security.domain.Authorite.authoriteResultMap";

    @ResultMap(AUTHORITE_RESULT_MAP)
    @SelectProvider(type = AuthoriteSqlProvider.class, method = "queryForPaginatedList")
    public List<T> queryForPaginatedList(Map<String, Object> map);

    @SelectProvider(type = AuthoriteSqlProvider.class, method = "getItemCount")
    public int getItemCount(Map<String, Object> map);

    @Insert("insert into sao_authorites(name,description,creator,create_time,update_man,update_time)values(#{name},#{description},#{creator},#{createTime},#{updateMan},#{updateTime})")
    public void saveAuthorite(T entity);

    @UpdateProvider(type = AuthoriteSqlProvider.class, method = "updateAuthorite")
    public void updateAuthorite(T entity);

    @ResultMap(AUTHORITE_RESULT_MAP)
    @SelectProvider(type = AuthoriteSqlProvider.class, method = "getAuthoriteByName")
    public T getAuthoriteByName(String account);

    @ResultMap(AUTHORITE_RESULT_MAP)
    @SelectProvider(type = AuthoriteSqlProvider.class, method = "getAuthoriteById")
    public T getAuthoriteById(int id);

    @Select("SELECT DISTINCT sa.name FROM sao_authorites sa")
	public List<String> getAllAuthoritieName();

}
